extends Button



func _ready():
	set_value(1)
	


func _on_ItemSelect_button_up():
	var ui = MainTool.getUILayer().add_ui("res://tool/common/PopUp/ListSearchPopup.tscn", 0, false)
	ui.popup_centered()
	ui.init_data_items(funcref(self, "_on_select_item"))


var cur_item_info

func _on_select_item(index, value):
	cur_item_info = DataSource.get_serie_item_list()[index]
	
	text = cur_item_info["name"]


func set_value(id):	
	var list = DataSource.get_serie_item_list()
	for i in range(list.size()):
		var item = list[i]
		if item["id"] == id:
			text = item["name"]
			cur_item_info = item
			return
	
	_on_clear_button_up()

func get_value():
	if cur_item_info:
		return cur_item_info["id"]
	else:
		return -1
		


func _on_clear_button_up():
	cur_item_info = null
	text = ""
	hint_tooltip = text
